package com.spark.rdd

import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by Administrator on 2017/5/18.
  */
object sparkInput {

  def main(args: Array[String]): Unit = {

    //设置本机Spark配置
    val conf = new SparkConf().setAppName("wordCount").setMaster("local")
    //创建Spark上下
    val sc = new SparkContext(conf)
    //从文件中获取数据
    val input = sc.textFile("D:\\data\\video\\log\\2017-05-07\\txt\\cdn.v.zjol.com.cn;v-cdn.zjol.com.cn_2017-05-07_0.txt")

    val blankLines=sc.longAccumulator;

    val callSigns=input.flatMap(line=>{
      if(line==""){
        blankLines.add(1)
      }
      line.split(" ")
    })


    callSigns.saveAsTextFile("output.txt")
    println("blank lines "+blankLines.value)



  }

}
